@inherits AntDesignTestBase
@code {
	[Fact]
	public void Renders_basic_tag()
	{
		var cut = Context.Render(@<AntDesign.Tag>Tag 1</AntDesign.Tag>);		
		cut.MarkupMatches(@<span class="ant-tag ant-tag-default" id:ignore>Tag 1</span>);
	}

	[Fact]
	public void Renders_basic_tag_invisible()
	{
		var cut = Context.Render(@<AntDesign.Tag Visible="false"> Tag 1</AntDesign.Tag>);		
		cut.MarkupMatches(@<span class="ant-tag ant-tag-default ant-tag-hidden" id:ignore>Tag 1</span>);
	}

	[Theory]
	[InlineData("success", "ant-tag-success")]
	[InlineData("processing", "ant-tag-processing")]
	[InlineData("error", "ant-tag-error")]
	[InlineData("MAGENTA", "ant-tag-magenta")]
	[InlineData("blue-inverse", "ant-tag-blue-inverse")]
	[InlineData("", "ant-tag-default")]
	[InlineData(null, "ant-tag-default")]
	public void Renders_predefined_tag(string color, string expectedClass)
	{
		var cut = Context.Render(@<AntDesign.Tag Color="@color">Tag 1</AntDesign.Tag>);		
		cut.MarkupMatches(@<span class="ant-tag @expectedClass" id:ignore>Tag 1</span>);
	}

	[Fact]
	public void Closes_tag()
	{
		var cut = Context.Render<AntDesign.Tag>(@<AntDesign.Tag Closable>Tag 1</AntDesign.Tag>);
		var icon = cut.Find("span.anticon");
		icon.Click();
		cut.MarkupMatches(string.Empty);
	}

	[Fact]
	public void Prevents_tag_closing()
	{
		Action<CloseEventArgs<MouseEventArgs>> onClosing = value => { value.Cancel = true; };
		var cut = Context.Render<AntDesign.Tag>(@<AntDesign.Tag Closable OnClosing="onClosing">Tag 1</AntDesign.Tag>);
		var icon = cut.Find("span.anticon");
		icon.Click();
		cut.MarkupMatches(@<span class:ignore id:ignore >Tag 1
            <span role="img" class="anticon anticon-close" id:ignore   tabindex="-1" >       
                <svg focusable="false" width="1em" height="1em" fill="currentColor" style="pointer-events: none;" xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 1024 1024">
                    <path d:ignore></path>
                </svg>
            </span>
        </span>
    );
    }

    [Fact]
    public void OnClose_gets_called()
    {
        var called = false;

        Action<MouseEventArgs> onClose = value => { called = true; };

		var cut = Context.Render<AntDesign.Tag>(@<AntDesign.Tag Closable OnClose="onClose">Tag 1</AntDesign.Tag>);
		var icon = cut.Find("span.anticon");
		icon.Click();

        called.Should().BeTrue();
    }

    [Fact]
    public void OnClick_gets_called()
    {
        var called = false;

        Action onClick = () => { called = true; };

		var cut = Context.Render<AntDesign.Tag>(@<AntDesign.Tag Closable OnClick="onClick">Tag 1</AntDesign.Tag>);
        cut.Find(".ant-tag").Click();

        called.Should().BeTrue();
    }

	[Fact]
	public void Click_on_close_does_not_invoke_OnClick()
	{
		bool isOnClickCalled = false;
		Action onClick = () => { isOnClickCalled = true; };
		var cut = Context.Render<AntDesign.Tag>(@<AntDesign.Tag Closable OnClick="onClick">Tag 1</AntDesign.Tag>);
		var icon = cut.Find("span.anticon");
		icon.Click();
		isOnClickCalled.Should().BeFalse();
	}

	[Fact]
	public void Click_changes_Checked()
	{
		var cut = Context.Render<AntDesign.Tag>(@<AntDesign.Tag Checkable>Tag 1</AntDesign.Tag>);			
		var tag = cut.Find("span.ant-tag");
		tag.Click();
		cut.Instance.Checked.Should().BeTrue();
	}

	[Fact]
	public void Checked_change_invokes_callback()
	{
		bool isCheckedChangeCalled = false;
		Action<bool> onCheckedChange = (value) => { isCheckedChangeCalled = true; };
		var cut = Context.Render<AntDesign.Tag>(@<AntDesign.Tag Checkable CheckedChanged="onCheckedChange">Tag 1</AntDesign.Tag>);			
		var tag = cut.Find("span.ant-tag");
		tag.Click();
		isCheckedChangeCalled.Should().BeTrue();
	}

	[Fact]
	public void Renders_custom_style_and_custom_color_tag()
    {
		var cut = Context.Render(@<AntDesign.Tag Color="#108ee9" Style="margin-left:5px;">Tag 1</AntDesign.Tag>);
        cut.MarkupMatches(@<span class="ant-tag ant-tag-has-color" id:ignore style="margin-left: 5px; background-color: #108ee9; ">Tag 1</span>);
    }
}
}